/*
 *    Copyright (C) 2011-2012 Hai Bison
 *
 *    See the file LICENSE at the root directory of this project for copying
 *    permission.
 */


package group.pals.mailgate.beans;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.mail.Flags;

/**
 *
 * @author Hai Bison
 */
public class ItemEmailMessage {

    private final String ID;
    private final String Sender;
    private final String Subject;
    private final Date ReceivedDate;
    private final String TextSnippet;
    private final Map<Flags.Flag, Boolean> EmailFlags;
    private final boolean HasAttachment;
    /**
     * Flag to mark if the message is new.
     */
    private boolean newMessage = false;

    public ItemEmailMessage(String ID, String sender, String subject, Date receivedDate,
            String textSnippet, boolean hasAttachment) {
        this.ID = ID;
        this.Sender = sender;
        this.Subject = subject;
        this.ReceivedDate = receivedDate;
        this.TextSnippet = textSnippet;
        this.HasAttachment = hasAttachment;
        this.EmailFlags = new HashMap<Flags.Flag, Boolean>();
    }

    /**
     * @return the message's subject, can be <code>null</code>.
     */
    @Override
    public String toString() {
        return getSubject();
    }

    /**
     * @return the subject
     */
    public String getSubject() {
        return Subject;
    }

    /**
     * @return the receivedDate
     */
    public Date getReceivedDate() {
        return ReceivedDate;
    }

    /**
     * @return the textSnippet
     */
    public String getTextSnippet() {
        return TextSnippet;
    }

    /**
     * @return the sender
     */
    public String getSender() {
        return Sender;
    }

    /**
     * @return the ID
     */
    public String getID() {
        return ID;
    }

    public void setFlag(Flags.Flag flag, boolean set) {
        this.EmailFlags.put(flag, set);
    }

    /**
     * @return the flags
     */
    public Map<Flags.Flag, Boolean> getFlags() {
        return EmailFlags;
    }

    /**
     * @return {@code true} if the e-mail has attachment
     */
    public boolean hasAttachment() {
        return HasAttachment;
    }

    /**
     * @return the newMessage
     */
    public boolean isNewMessage() {
        return newMessage;
    }

    /**
     * @param newMessage the newMessage to set
     */
    public void setNewMessage(boolean newMessage) {
        this.newMessage = newMessage;
    }
}
